//
//  NoticeViewController.m
//  Haliaeetus
//
//  Created by junli hou on 2018/4/30.
//  Copyright © 2018年 BMY. All rights reserved.
//

#import "NoticeViewController.h"
#import "OrderSuccessViewController.h"

@interface NoticeViewController ()
@property (nonatomic, strong) UIButton *agreeBtn;
@property (nonatomic, strong) UIButton *nextBtn;
@property (nonatomic,assign) Boolean isAgree;
@property (nonatomic, strong) UITextView * couponCodeTextView;
@property (nonatomic, strong) UITextField * couponCodeTextfiled;
@property (nonatomic, strong) UIButton *couponCodeBtn;
@property(nonatomic,strong)UIView *bgView;
@property(nonatomic,strong)UIView *shareView;
@property(nonatomic,strong)UIView *waitPayView;
@property(nonatomic,strong)UILabel *waitPayLabel;
@property(nonatomic,strong)UILabel *waitPayMoneyLabel;
@property(nonatomic,strong)UILabel *waitPayContentLabel;
@property(nonatomic,strong)UIButton *payBtn;
@property(nonatomic,strong)UIButton *cancelBtn;
@property(nonatomic,strong)UITextView *noticeLabel2;
@property(nonatomic,strong)UIView *bottomLine;
@property(nonatomic,strong)UIView *centerLine;
@property(nonatomic,strong)UILabel *agreeLabel;
@end

@implementation NoticeViewController
- (instancetype)initWithOrderNextBlock:(OrderNextBlock)orderNextBlock
{
    self = [super init];
    if (self) {
        _orderNextBlock = orderNextBlock;
        
    }
    return self;
}
- (void)loadView {
    [super loadView];
    self.title =@"房间预定";
    self.view.backgroundColor = [UIColor whiteColor];
    self.isAgree=NO;
    self.edgesForExtendedLayout = UIRectEdgeNone;
    [self.navigationController setLeftBtnWithTarget:self action:@selector(goBack)];
    self.isFirst=[[self.dataDic objectForKey:@"can_use_coupon"] boolValue];
    [self initView];
    
}
- (void)goBack {
    [self.navigationController popViewControllerAnimated:YES];
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(updateWXPay:) name:@"UpdateWXPay"object:Nil];
 
    
    
}
- (void)initView
{
    
    
    
   UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0,30,WS_SCREEN_FRAME_WIDTH,26)];
   titleLabel.text = @"下单须知";
    titleLabel.textAlignment=NSTextAlignmentCenter;
    titleLabel.textColor = WS_RGBA(51,51,51,1);
    titleLabel.font = [UIFont systemFontOfSize:16];
    [self.view addSubview:titleLabel];
    
    
    UIView *pointView1 = [[UIView alloc]initWithFrame:CGRectMake(27,106,5,5)];
    pointView1.layer.cornerRadius=2.5;
    pointView1.layer.masksToBounds = YES;
    pointView1.backgroundColor = WS_RGB(93, 93, 93);
    [self.view addSubview:pointView1];
    
    UITextView *noticeLabel1 = [[UITextView alloc]initWithFrame:CGRectMake(42,97,WS_SCREEN_FRAME_WIDTH-42-26,48)];
    noticeLabel1.text = @"特价酒店有特定限制，可能不允许取消，请仔 细阅读酒店的限制条款。";
    noticeLabel1.textAlignment=NSTextAlignmentLeft;
    noticeLabel1.textColor = WS_RGBA(102,102,102,1);
    noticeLabel1.font = [UIFont systemFontOfSize:12];
    [self.view addSubview:noticeLabel1];
    
    UIView *pointView2 = [[UIView alloc]initWithFrame:CGRectMake(27,177,5,5)];
    pointView2.layer.cornerRadius=2.5;
    pointView2.layer.masksToBounds = YES;
    pointView2.backgroundColor = WS_RGB(93, 93, 93);
    [self.view addSubview:pointView2];
    
    self.noticeLabel2 = [[UITextView alloc]initWithFrame:CGRectMake(42,CGRectGetMaxY(noticeLabel1.frame)+24,WS_SCREEN_FRAME_WIDTH-42-26,48)];
    self.noticeLabel2.text =[NSString stringWithFormat:@"本订单需要额外支付手续费%@元，特预约一经确认概不退款。(手续费用为每日100元)",[NSString stringWithFormat:@"%.2f",[[self.dataDic objectForKey:@"commission"]floatValue]]];
    self.noticeLabel2.textAlignment=NSTextAlignmentLeft;
    self.noticeLabel2.textColor = WS_RGBA(102,102,102,1);
    self.noticeLabel2.font = [UIFont systemFontOfSize:12];
    [self.view addSubview:self.noticeLabel2];
 

    
    self.couponCodeTextView= [[UITextView alloc]initWithFrame:CGRectMake(42,CGRectGetMaxY(self.noticeLabel2.frame)+40,WS_SCREEN_FRAME_WIDTH-42-26,48)];
    self.couponCodeTextView.text =@"*该订单可使用优惠码获取手续费优惠";
    self.couponCodeTextView.textAlignment=NSTextAlignmentLeft;
    self.couponCodeTextView.textColor = WS_RGBA(102,102,102,1);
    self.couponCodeTextView.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:self.couponCodeTextView];
    
    
    
    self.couponCodeTextfiled= [[UITextField alloc]initWithFrame:CGRectMake(42,CGRectGetMaxY(self.couponCodeTextView.frame)+10,200,30)];
    self.couponCodeTextfiled.placeholder=@"请输入优惠码";
    self.couponCodeTextfiled.textAlignment=NSTextAlignmentLeft;
    self.couponCodeTextfiled.textColor = WS_RGBA(102,102,102,1);
    self.couponCodeTextfiled.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:self.couponCodeTextfiled];
    
    self.bottomLine=[[UIView alloc]init];
    self.bottomLine.frame=CGRectMake(42, CGRectGetMaxY(self.couponCodeTextfiled.frame), WS_SCREEN_FRAME_WIDTH-84, 0.5);
    self.bottomLine.backgroundColor=WS_RGB(153, 153, 153);
    [self.view addSubview:self.bottomLine];
    
    
    //验证优惠码
    self.couponCodeBtn = [[UIButton alloc]init];
    self.couponCodeBtn.frame =CGRectMake(WS_SCREEN_FRAME_WIDTH-140,CGRectGetMaxY(self.couponCodeTextView.frame)+10,100,30);
//    self.couponCodeBtn.layer.cornerRadius=2;
//    self.couponCodeBtn.layer.masksToBounds = YES;
//    self.couponCodeBtn.backgroundColor = WS_RGB(218, 218, 218);
    self.couponCodeBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [self.couponCodeBtn setTitleColor:WS_RGB(255, 134, 35) forState:UIControlStateNormal];
    [self.couponCodeBtn setTitle:@"验证优惠码" forState:UIControlStateNormal];
    [self.couponCodeBtn addTarget:self action:@selector(confirmationCouponCode) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.couponCodeBtn];
    
    
    self.centerLine=[[UIView alloc]init];
    self.centerLine.frame=CGRectMake(WS_SCREEN_FRAME_WIDTH-145, CGRectGetMaxY(self.couponCodeTextView.frame)+10+5, 0.5, 20);
    self.centerLine.backgroundColor=WS_RGB(153, 153, 153);
    [self.view addSubview:self.centerLine];
    
    if (self.isFirst) {
        self.couponCodeTextView.hidden=false;
        self.couponCodeBtn.hidden=false;
        self.couponCodeTextfiled.hidden=false;
    }else{
        self.couponCodeTextView.hidden=true;
        self.couponCodeBtn.hidden=true;
        self.couponCodeTextfiled.hidden=true;
    }
    
    
    //save
    self.agreeBtn = [[UIButton alloc]init];
    self.agreeBtn.frame =CGRectMake(157,WS_SCREEN_FRAME_HEIGHT-102-64-20,18,18);
    self.agreeBtn.layer.masksToBounds = YES;
    self.agreeBtn.layer.cornerRadius = 2;
    self.agreeBtn.layer.borderWidth = 1;
    self.agreeBtn.layer.borderColor = [WS_RGBA(153, 153, 153, 1)  CGColor];
    [self.agreeBtn addTarget:self action:@selector(agreeNotice) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.agreeBtn];
    
    
    self.agreeLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.agreeBtn.frame)+5,WS_SCREEN_FRAME_HEIGHT-102-64-20,60,18)];
    self.agreeLabel.text = @"我同意";
    self.agreeLabel.textAlignment=NSTextAlignmentLeft;
    self.agreeLabel.textColor = WS_RGBA(153,153,153,1);
    self.agreeLabel.font = [UIFont systemFontOfSize:13];
    [self.view addSubview:self.agreeLabel];
    
    
    
    //save
    self.nextBtn = [[UIButton alloc]init];
    self.nextBtn.frame =CGRectMake(15,CGRectGetMaxY(self.agreeBtn.frame) + 18,WS_SCREEN_FRAME_WIDTH-30,40);
    self.nextBtn.layer.cornerRadius=2;
    self.nextBtn.layer.masksToBounds = YES;
    self.nextBtn.backgroundColor = WS_RGB(218, 218, 218);
    self.nextBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [self.nextBtn setTitleColor:WS_RGB(255, 255, 255) forState:UIControlStateNormal];
    [self.nextBtn setTitle:@"继续下单" forState:UIControlStateNormal];
    [self.nextBtn addTarget:self action:@selector(nextAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.nextBtn];
    
    
//    if (!self.isEnough) {
//        [self showWaitPayView:self.dataDic];
//    }
}
-(void)confirmationCouponCode{
    
    
    if ([self.couponCodeTextfiled.text isEqualToString:@""] || self.couponCodeTextfiled.text.length == 0) {
        WSToast(@"请输入需要验证的优惠码");
    }else{
        [self requestVerifyCoupon];
    }
    
}
-(void)agreeNotice
{
    if (!self.isAgree) {
        [self.agreeBtn setImage:[UIImage imageNamed:@"agree_icon"] forState:UIControlStateNormal];
        self.isAgree=YES;
        self.nextBtn.backgroundColor = WS_RGB(255, 134, 35);
        self.nextBtn.titleLabel.font = [UIFont systemFontOfSize:16];
        [self.nextBtn setTitleColor:WS_RGB(255, 255, 255) forState:UIControlStateNormal];
        
    }else{
         [self.agreeBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
         self.isAgree=NO;
        self.nextBtn.backgroundColor = WS_RGB(218, 218, 218);
        self.nextBtn.titleLabel.font = [UIFont systemFontOfSize:16];
        [self.nextBtn setTitleColor:WS_RGB(255, 255, 255) forState:UIControlStateNormal];
    }
    
}

-(void)nextAction
{
    if (!self.isAgree) {
        WSToast(@"请同意服务条款，再继续操作");
    }else{
////
////        self.orderNextBlock();
//        [self goBack];
        [self requestConfirmSchedules];
    }
    
}

-(void)initWaitPayView:(NSDictionary*)infoDic{
    UIWindow *window = [[UIApplication sharedApplication].delegate window];
    self.bgView = [window.rootViewController.view viewWithTag:100];
    if (self.bgView==NULL) {
        self.bgView =[[UIView alloc]init];
        self.bgView.frame=CGRectMake(0, 0, WS_SCREEN_FRAME_WIDTH, WS_SCREEN_FRAME_HEIGHT) ;
        self.bgView.backgroundColor=[UIColor blackColor];
        self.bgView.tag=100;
        self.bgView.alpha=0.6;
        [window.rootViewController.view addSubview:self.bgView];
    }
    
    self.waitPayView = [window.rootViewController.view viewWithTag:80];
    
    if (self.waitPayView==NULL) {
        self.waitPayView =[[UIView alloc]init];
        self.waitPayView.frame=CGRectMake((WS_SCREEN_FRAME_WIDTH-340)/2, (WS_SCREEN_FRAME_HEIGHT-320)/2, 340, 320) ;
        self.waitPayView.backgroundColor=[UIColor whiteColor];
        self.waitPayView.layer.masksToBounds = YES;
        self.waitPayView.tag=80;
        
        self.waitPayView.layer.cornerRadius = 2;
        [window.rootViewController.view addSubview:self.waitPayView];
        
        
        self.waitPayLabel = [[UILabel alloc]init];
        self.waitPayLabel.frame = CGRectMake(0,49,340,40);
        self.waitPayLabel.font = [UIFont systemFontOfSize:18];
        self.waitPayLabel.numberOfLines=1;
        self.waitPayLabel.textAlignment=NSTextAlignmentCenter;

        self.waitPayLabel.textColor = WS_RGB(68, 69, 60);
        [self.waitPayView addSubview:self.waitPayLabel];
        
        self.waitPayMoneyLabel = [[UILabel alloc]init];
        self.waitPayMoneyLabel.frame = CGRectMake(0,CGRectGetMaxY(self.waitPayLabel.frame),340,30);
        self.waitPayMoneyLabel.font = [UIFont systemFontOfSize:12];
        self.waitPayMoneyLabel.numberOfLines=1;
        self.waitPayMoneyLabel.textAlignment=NSTextAlignmentCenter;
       
        self.waitPayMoneyLabel.textColor = WS_RGB(153, 153, 153);
        [self.waitPayView addSubview:self.waitPayMoneyLabel];
        
        self.waitPayContentLabel = [[UILabel alloc]init];
        self.waitPayContentLabel.frame = CGRectMake(20,CGRectGetMaxY(self.waitPayMoneyLabel.frame)+20,300,35);
        self.waitPayContentLabel.font = [UIFont systemFontOfSize:12];
        self.waitPayContentLabel.numberOfLines=2;
        self.waitPayContentLabel.textAlignment=NSTextAlignmentCenter;

        self.waitPayContentLabel.textColor =  WS_RGB(153, 153, 153);
        [self.waitPayView addSubview:self.waitPayContentLabel];
        
        //立即支付
        self.payBtn = [[UIButton alloc]init];
        self.payBtn.frame =CGRectMake(50,CGRectGetMaxY(self.waitPayContentLabel.frame)+40,240,40);
        self.payBtn.layer.cornerRadius=2;
        self.payBtn.layer.masksToBounds = YES;
        self.payBtn.backgroundColor = WS_RGB(255, 134, 35);
        self.payBtn.titleLabel.font = [UIFont systemFontOfSize:16];
        [self.payBtn setTitleColor:WS_RGB(255, 255, 255) forState:UIControlStateNormal];
        [self.payBtn setTitle:@"微信支付" forState:UIControlStateNormal];
        [self.payBtn addTarget:self action:@selector(payAction) forControlEvents:UIControlEventTouchUpInside];
        [self.waitPayView addSubview:self.payBtn];
        
        
        self.cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        self.cancelBtn.frame = CGRectMake(50,CGRectGetMaxY(self.payBtn.frame)+10,240,40);

        [self.cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
        self.cancelBtn.titleLabel.font = [UIFont systemFontOfSize: 16.0];
        [self.cancelBtn setTitleColor:WS_RGBA(68, 69, 60, 1) forState:UIControlStateNormal];
        self.cancelBtn.layer.masksToBounds = YES;
        self.cancelBtn.layer.cornerRadius = 3;
        self.cancelBtn.layer.borderWidth = 1;
        self.cancelBtn.layer.borderColor = [WS_RGBA(155, 155, 155, 1)  CGColor];
        [self.cancelBtn addTarget:self action:@selector(cancelAction) forControlEvents:UIControlEventTouchUpInside];
        [self.waitPayView addSubview:self.cancelBtn];
        
    }
        self.waitPayLabel.text=[NSString stringWithFormat:@"本订单需要手续费%@元",[NSString stringWithFormat:@"%.2f",[[self.dataDic objectForKey:@"commission"]floatValue]]];
        self.waitPayContentLabel.text=[NSString stringWithFormat:@"当前余额：%@元",[NSString stringWithFormat:@"%.2f",[[self.dataDic objectForKey:@"balance"]floatValue]]];
        self.waitPayMoneyLabel.text=[NSString stringWithFormat:@"您的账户余额不足，请充值：%@元",[NSString stringWithFormat:@"%.2f",[[self.dataDic objectForKey:@"commission"]floatValue]]];
}

-(void)cancelAction{
    
    [self hiddenWaitPayView];
}

- (void)updateWXPay:(NSNotification*) notification
{
    
    BaseResp* resp=notification.object;
    
    switch (resp.errCode) {
        case WXSuccess:
            
            [self getPayStatus];
            break;
        case WXErrCodeCommon:
            
            WSToast(@"支付失败!");
            
            break;
        case WXErrCodeUserCancel:
            
            
            WSToast(@"支付取消!");
            break;
        case WXErrCodeSentFail:
            
            WSToast(@"支付失败!");
            
            break;
        default:
            
            
            break;
    }
}
-(void)showWaitPayView:(NSDictionary*)info{
    [self initWaitPayView:info];
    self.bgView.hidden=NO;
    self.waitPayView.hidden=NO;
    
}
-(void)hiddenWaitPayView{
    
    if (self.waitPayView) {
        self.bgView.hidden=YES;
        self.waitPayView.hidden=YES;
    }
}

-(void)payAction{
    
    /*
     OrderSuccessViewController *orderSuccessViewController=[[OrderSuccessViewController alloc]init];
     orderSuccessViewController.hidesBottomBarWhenPushed=YES;
     [self.navigationController pushViewController:orderSuccessViewController animated:YES];
     */
    
    [self getWeiXinPayInfo];
    
}

#pragma mark   ==============点击订单模拟支付行为==============
// 选中商品调用支付宝极简支付
-(void)weixinPay:(NSDictionary *)wxpayModel
{
    
    
    
    [WXApi registerApp:[NSString stringWithFormat:@"%@",[wxpayModel objectForKey:@"appid"]]];
    //调起微信支付
    PayReq* req             = [[PayReq alloc] init];
    req.openID              = [NSString stringWithFormat:@"%@",[wxpayModel objectForKey:@"appid"]];
    req.partnerId           = [NSString stringWithFormat:@"%@",[wxpayModel objectForKey:@"partnerid"]];
    req.prepayId            = [NSString stringWithFormat:@"%@",[wxpayModel objectForKey:@"prepayid"]];
    req.nonceStr            = [NSString stringWithFormat:@"%@",[wxpayModel objectForKey:@"noncestr"]];
    req.timeStamp           = [NSString stringWithFormat:@"%@",[wxpayModel objectForKey:@"timestamp"]].intValue;
    req.package             = [NSString stringWithFormat:@"%@",[wxpayModel objectForKey:@"package_value"]];
    req.sign                = [NSString stringWithFormat:@"%@",[wxpayModel objectForKey:@"sign"]];
    
    [WXApi sendReq:req];
    
}
#pragma mark - 微信支付
- (void)getWeiXinPayInfo
{
    
    [SVProgressHUD showWithStatus:@"loading"];
    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeBlack];
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    [params setValue:[self.dataDic objectForKey:@"order_sn"] forKey:@"order_sn"];
    [WSNetwork WSHttpsByType:@"GET" Url:[NSString stringWithFormat:@"%@%@",BMY_URL,@"/payments/wxpay_app"] params:params onCompletion:^(NSMutableDictionary *dic){
        [SVProgressHUD dismiss];
        
        
        if ([[dic objectForKey:@"biz_action"] intValue] == 0) {
            NSDictionary *DataDic=(NSDictionary*) [dic objectForKey:@"data"];
            [self weixinPay:[DataDic objectForKey:@"pay_params"]];
            
            
            
        }else{
            
            //请求出错
            WSToast([dic objectForKey:@"biz_msg"]);
        }
    } onError:^(NSError *error) {
        
        if (error.code==99999) {
            WSToast(@"网络异常，请检查网络设置!");
        }
        [SVProgressHUD dismiss];
        
    }];
    
}
#pragma mark -支付轮询
- (void)getPayStatus
{
    
    [SVProgressHUD showWithStatus:@"loading"];
    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeBlack];

    [WSNetwork WSHttpsByType:@"GET" Url:[NSString stringWithFormat:@"%@/orders/%@/pay_state",BMY_URL,[self.dataDic objectForKey:@"order_sn"]] params:NULL onCompletion:^(NSMutableDictionary *dic){
        [SVProgressHUD dismiss];
        
        
        if ([[dic objectForKey:@"biz_action"] intValue] == 0) {
           
            [self hiddenWaitPayView];
            WSToast(@"充值成功，请继续下单");

            
        }else if([[dic objectForKey:@"biz_action"] intValue] == 2){
            [self getPayStatus];
        }else{
            
            //请求出错
            WSToast([dic objectForKey:@"biz_msg"]);
        }
    } onError:^(NSError *error) {
        
        if (error.code==99999) {
            WSToast(@"支付异常，请联系客服!");
        }
        [SVProgressHUD dismiss];
        
    }];
    
}
#pragma mark - 验证优惠码
- (void)requestVerifyCoupon
{
    
    [SVProgressHUD showWithStatus:@"loading"];
    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeBlack];
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    [params setValue:self.couponCodeTextfiled.text forKey:@"coupon_sn"];
    [WSNetwork WSHttpsByType:@"POST" Url:[NSString stringWithFormat:@"%@/schedules/%@%@",BMY_URL,[self.dataDic objectForKey:@"schedule_id"],@"/verify_coupon"] params:params onCompletion:^(NSMutableDictionary *dic){
        [SVProgressHUD dismiss];
        
        
        if ([[dic objectForKey:@"biz_action"] intValue] == 0) {
         NSDictionary *dataDic=(NSDictionary*) [dic objectForKey:@"data"];
            WSToast([dic objectForKey:@"biz_msg"]);
            self.couponCodeTextView.hidden=true;
            self.couponCodeBtn.hidden=true;
            self.couponCodeTextfiled.hidden=true;
            self.bottomLine.hidden=true;
            self.centerLine.hidden=true;
            
      
//            [self weixinPay:[DataDic objectForKey:@"pay_params"]];
            
            self.noticeLabel2.text =[NSString stringWithFormat:@"本订单需要额外支付手续费%@元(优惠券已抵扣%@元)，特预约一经确认概不退款。(手续费用为每日100元)",[NSString stringWithFormat:@"%.2f",[[dataDic objectForKey:@"commission"]floatValue]],[NSString stringWithFormat:@"%.2f",[[dataDic objectForKey:@"coupon_amount"]floatValue]]];
        }else{
            
            //请求出错
            WSToast([dic objectForKey:@"biz_msg"]);
        }
    } onError:^(NSError *error) {
        
        if (error.code==99999) {
            WSToast(@"网络异常，请检查网络设置!");
        }
        [SVProgressHUD dismiss];
        
    }];
    
}

#pragma mark - 确认行程
- (void)requestConfirmSchedules
{
    
    [SVProgressHUD showWithStatus:@"loading"];
    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeBlack];
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
     [params setValue:self.couponCodeTextfiled.text forKey:@"coupon_sn"];
    [WSNetwork WSHttpsByType:@"POST" Url:[NSString stringWithFormat:@"%@/schedules/%@/confirm",BMY_URL,[self.dataDic objectForKey:@"schedule_id"]] params:params onCompletion:^(NSMutableDictionary *dic){
        [SVProgressHUD dismiss];
        
        
        if ([[dic objectForKey:@"biz_action"] intValue] == 0) {
            WSToast([dic objectForKey:@"biz_msg"]);
            self.orderNextBlock();
            [self.navigationController popViewControllerAnimated:NO];

        }else if ([[dic objectForKey:@"biz_action"] intValue] == 2) {
            NSDictionary *DataDic=(NSDictionary*) [dic objectForKey:@"data"];
            self.dataDic=DataDic;
            [self showWaitPayView:self.dataDic];
            WSToast([dic objectForKey:@"biz_msg"]);
            
        }else{
            
            //请求出错
            WSToast([dic objectForKey:@"biz_msg"]);
        }
    } onError:^(NSError *error) {
        
        if (error.code==99999) {
            WSToast(@"网络异常，请检查网络设置!");
        }
        [SVProgressHUD dismiss];
        
    }];
    
}


-(void)dealloc{
    
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
